<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://web.study.tag" prefix="ct"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page import="web.study.freemarker.*"%>
<!-- 使用forEach标签产生1个10至200之间的随机数 -->
<c:forEach begin="1" end="1">
	<!-- 调用random标签 -->
	<ct:random min="10" max="200"> 11111111111</ct:random>
	<ct:invokeOrder attr1="1" attr2="2">123</ct:invokeOrder>
</c:forEach>
<ct:displayBody>如果存在请求参数body，则输出标签体的内容 </ct:displayBody>
<%
    java.util.List<java.util.List> rows = new java.util.ArrayList<java.util.List>();
    java.util.List row1 = new java.util.ArrayList();
    java.util.List row2 = new java.util.ArrayList();
    
    java.util.List row3 = new java.util.ArrayList();
    row1.add("足球");
    row1.add(30);
    row1.add(12);
    row2.add("跑步机");
    row2.add(321);
    row2.add(25);
    row3.add("自行车");
    row3.add(221);
    row3.add(6);
    rows.add(row1);
    rows.add(row2);
    rows.add(row3);
    request.setAttribute("rows", rows);
%>
<table border="1">
	<tr>
		<th>商品名称</th>
		<th>单价</th>
		<th>数量</th>
	</tr>
	<c:forEach items="${rows}">
		<!-- 生成表格的行代码 -->
		<ct:tr />
	</c:forEach>
</table>
sin(π) = <ct:math value="3.14" method="sin" />&nbsp;&nbsp;&nbsp;&nbsp; 
cos(π) = <ct:math value="3.14" method="cos" /><br> 
tan(1.45) = <ct:math value="1.45" method="tan" /><br> 
sin(90°) = <ct:math value="90" method="sin" angle="true" /><br> 
sin(50°) = <ct:math value="50" method="sin" angle="true" pattern="0.0000" /><br> 
tan(39°) = <ct:math value="39" method="tan" angle="true" pattern="0.00000" /><br> 
sqrt(25) = <ct:math value="25" method="sqrt" pattern="0.0" /><br> 
log(221) = <ct:math value="221" method="log" pattern="0.0000" />（以e为底的对数）

<!-- 如果method和value请求参数不为null，调用dynMath标签进行数学运算 -->
<c:if test="${param.method != null && param.value != null}"> 
${param.method}(${param.value}${param.angle=='true'?'°':''})= <ct:dynMath
		value="${param.value}" method="${param.method}"
		angle="${(param.angle == '')?'false':param.angle}"
		pattern="${param.pattern == ''?'0.00':param.pattern}" />
</c:if>
<form method="post">
	<table>
		<tr>
			<td>方法名：</td>
			<td><input type="text" name="method" value="${param.method}" /></td>
		</tr>
		<tr>
			<td>参数值：</td>
			<td><input type="text" name="value" value="${param.value}" /></td>
		</tr>
		<tr>
			<td>是否为角度：</td>
			<td><input type="checkbox" name="angle" value="true"
				${param.angle == 'true'?"checked='checked'":''} /></td>
		</tr>
		<tr>
			<td>模式字符串：</td>
			<td><input type="text" name="pattern" value="${param.pattern}" />
			</td>
		</tr>
	</table>
	<p />
		<input type="submit" value="计算" /></form>
<!-- freemarker test -->		
<%
FirstFreemarker fm =new FirstFreemarker();
fm.execute(pageContext);
%>
<ct:localPage></ct:localPage>
